export function throttle (fn, delay, duration) {
  const that = this
  let begin = Date.now()
  let timer = null
  return function timeout (...args) {
    const now = Date.now()
    console.log(now - begin >= duration)
    if (now - begin >= duration) {
      clearTimeout(timer)
      console.log(888)
      fn.apply(that, args)
      begin = Date.now()
    } else {
      clearTimeout(timer)
      console.log(999)
      timer = setTimeout((arg) => {
        fn.apply(that, arg)
      }, delay, args)
    }
  }
}
